<?php

namespace app\admin\model;

use think\Model;

class DecorationLive extends Model
{
    // 设置当前模型对应的完整数据表名称
    // protected $table = 'k_decoration_images';

    // 将图相对地址片转为网络地址
    public function getImagesAttr($value)
    {
        $url = "http://huaxiaoujia.com";
        $img = explode(',', $value);
        foreach ($img as $k => $v) {
            $img[$k] = $url . $v;
        }
        return $img;
    }

    public function getTypeAttr($value)
    {
        return config('config')['live_status'][$value];
    }

    public function getTimeAttr($value)
    {
        return date("Y-m-d", $value);
    }

    public function getUserAttr($value)
    {
        return model("UserType")->alias('a')->join("k_users b", "a.user_id = b.user_id")->field("name,type,head_pic as headPic")->find($value);
    }
}
